#include <iostream>
#include <vector>

class Shape
{
public:
    virtual double area() = 0;
    virtual ~Shape() = default;
};

class Rectangle : public Shape
{
public:
    Rectangle(double length, double width) : width(width), length(length) {}
    double area()
    {
        return width * length;
    }

private:
    double width;
    double length;
};

class Circle : public Shape
{
public:
    Circle(double radius) : radius(radius) {}
    double area()
    {
        /*圆形面积*/
        return 3.14 * radius * radius;
    }

private:
    double radius;
};

class Square : public Shape
{
public:
    Square(int len) : m_len(len)
    {

    }

    double area()
    {
        return m_len * m_len;
    }
private:
     int m_len;
};


template <typename Container>
double calculateTotalArea(Container &shapes)
{
    double totalArea = 0.0;
    for (auto ite = shapes.begin(); ite != shapes.end(); ite++)
    {
        totalArea += (*ite)->area();
    }
    return totalArea;
}
int main()
{
    std::vector<Shape *> shapes;
    shapes.push_back(new Rectangle(3, 4));
    shapes.push_back(new Circle(5));
    shapes.push_back(new Square(10));

    double totalArea = calculateTotalArea(shapes);
    std::cout << "Total area: " << totalArea << std::endl;
    return 0;
}
